<include file="public/head"/>

<div class="form-group">
	<label for="input-controller" class="col-sm-2 control-label">表名称</label>
	<div class="col-md-6 col-sm-10">
		<select name="field_type" class="form-control" onchange="get_field($(this));" id="table_name">
			<option value="0">请选择</option>
			<foreach name="table_arr" item="vo">
				<option value="{$vo}">{$vo}</option>
			</foreach>
		</select>
	</div>
	<div class="col-md-6 col-sm-10" id="tbfields" style="margin-top:10px;">
	</div>
</div>

<script>
	//ajax获取字段
function get_field(obj){
    var tablename = $(obj).val()
	$.ajax({
		url:"{:cmf_plugin_url('QbtCustomModel://AdminModelField/get_field')}",
		data:{tablename:tablename},
		dataType:"json",
		type:"get",
		success:function (data) {
		    var str = "<label>连接字段名</label><select name=\"field_type\" class=\"form-control\" id='field_name'>";
			$.each(data,function (k,v) {
				str += "<option value='"+v+"'>"+v+"</option>"
            })
			str += "</select>"
			
			str += "<label>展示字段<span style='color: red'>(标题=字段名(多个以英文点好分隔))</span></label><input type='text' name=\"field_type\" class=\"form-control\" id='show_name'/>";
			$("#tbfields").html(str)
        }
	})
}
</script>
<include file="public/scripts"/>